﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using F_BLL;
using F_MODEL;

namespace MvcApplication1.Controllers
{
    public class MyWalletController : zyl_LoginController
    {
        MyWallet_bll bll = new MyWallet_bll();


        /// <summary>
        /// 交易明细--所有数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<TransactionDetail> Trans_show()
        {
            UserInfo m = new UserInfo();
            int userId = 0;
            m = mod();
            if(m!=null)
            userId = m.userId;
            return bll.Trans_show(userId);
        }

        /// <summary>
        /// 优惠券数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<Coupons> Coupons_show()
        {
            UserInfo m = new UserInfo();
            m = mod();
            int userId = m.userId;
            return bll.Coupons_show(userId);
        }
        /// <summary>
        /// 提现
        /// </summary>
        /// <param name="tixian"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        [HttpGet]
        public bool Tixian(string tixian,string userid)
        {
            TransactionDetail trans = new TransactionDetail();
            trans.userId = int.Parse(userid);
            trans.transactionId = DateTime.Now.ToString("yyyyMMddHHmmssfff") + userid;
            trans.transactionIsDel = 0;
            trans.transactionMoney = decimal.Parse(tixian);
            trans.transactionTime = DateTime.Now.ToLocalTime();
            trans.transactionTimeSpan = DateTime.Now.ToLocalTime();
            trans.transactionType = 1;
            trans.isPrivileged = 0;
            var xx= bll.Tixian(trans);
            return xx;
        }
    }
}
